<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
     //定义花色
     var colorCard = ['红桃','方片','梅花','黑桃'];
        //定义牌号
        var mathCard = ['A','2','3','4','5','6','7','8','9','10','J','Q','K'];
        //装牌数组
        var cards = new Array(54);                                  
        //定义牌索引
        var idx = 0;
        //将花色与牌号组合起来，放到cards里
        for(var i = 0; i < colorCard.length; i++){
            for(var j = 0; j < mathCard.length; j++){
                cards[idx++] = colorCard[i] + mathCard[j];
            }
        }
        //将大王小王放入卡数组
        cards[idx++] = '小王';
        cards[idx] = '大王'
        //输出看一下牌型
        document.write(cards)
        document.write("<hr/>")

        //定义三个用户牌数组以及索引
        var person1 = new Array(17);
        var person2 = new Array(17);
        var person3 = new Array(17);
        var index = 0;

        //分发三副牌
        for(var i = 0; i < person1.length; i++){
            //获取随机数
            var tmp = parseInt(Math.random() * cards.length);
            //将牌放入数组
            person1[i] = cards[tmp];
            //删除已取牌
            cards.splice(tmp,1);
        }
        //同上
        for(var i = 0; i < person2.length; i++){
            var tmp = parseInt(Math.random() * cards.length);
            person2[i] = cards[tmp];
            cards.splice(tmp,1);
        }
        for(var i = 0; i < person3.length; i++){
            var tmp = parseInt(Math.random() * cards.length);
            person3[i] = cards[tmp];
            cards.splice(tmp,1);
        }

        //排序
        person1.sort();
        person2.sort();
        person3.sort();
        //输出
        document.write("苏丽敏：" + person1);
        document.write("<hr/>")
        document.write("张尚坤：" + person2);
        document.write("<hr/>")
        document.write("张亚阳：" + person3);
        document.write("<hr/>")
        //剩余的牌为底牌
        document.write("底牌：" + cards);

    </script>
</body>

</html>